package weaver.formmode.customjavacode.modeexpand.crm;

import weaver.conn.RecordSet;
import weaver.file.ExcelParseForPOI;
import weaver.formmode.interfaces.ImportFieldTransActionPOI;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.hrm.User;

import java.util.Map;

/**
 * 说明
 * 修改时
 * 类名要与文件名保持一致
 * class文件存放位置与路径保持一致。
 * 请把编译后的class文件，放在对应的目录中才能生效
 * 注意 同一路径下java名不能相同。
 * @author Administrator
 *
 */
public class WeaYskmFieldTransPOI implements ImportFieldTransActionPOI{
    @Override
    public String getTransValue(Map<String, Object> param, User user, ExcelParseForPOI excelParse, int row, int col) {
        BaseBean baseBean = new BaseBean();
        baseBean.writeLog("----------YskmFieldTransPOI------------");
        baseBean.writeLog("-------param="+param);
        // 获取模块ID
        Integer modeId = Util.getIntValue(param.get("modeid").toString());
        baseBean.writeLog("modeId="+modeId);
        //表单id
        Integer formId = Util.getIntValue(param.get("formid").toString());
        baseBean.writeLog("formId="+formId);
        //当前字段id
        String fieldid = Util.null2String(param.get("fieldid"));
        baseBean.writeLog("fieldid="+fieldid);
        //当前字段名(明细表字段名为 d明细表顺序_明细表字段名 如  d1_mx1wb )
        String fieldname = Util.null2String(param.get("fieldname"));
        baseBean.writeLog("fieldname="+fieldname);
        //excel sheet顺序
        String sheetindex = Util.null2String(param.get("sheetindex"));
        baseBean.writeLog("sheetindex="+sheetindex);
        // 获取当前登录人员ID
        Integer userId = user.getUID();
        baseBean.writeLog("userId="+userId);
        //获取第 sheetindex 个sheet的第row行第col列的单元格的值 (下标都是从1开始)
        String value = excelParse.getValue(sheetindex, row, col);
        baseBean.writeLog("value="+value);
        //自定义转化逻辑   或者通过fieldid来判断
        RecordSet rs = new RecordSet();
        rs.executeQuery("select id from uf_yskmxx where sfzy='0' and kmjb='1' and ysfykm='"+value+"'");
        rs.next();
        String id= Util.null2String(rs.getString("id"));
        return id;
    }
}
